<template>
  <div class="liumian">
    <div v-if="!inline" class="content_title" style="cursor: pointer" @click="showDialogTech">
      <span class="content_text">梳棉</span>
      <img class="content_img" src="@/assets/img/chart/liumian.png" alt="" srcset="" />
    </div>
    <div class="liumian_body">
      <div v-if="!inline" class="peidianxiang">
        <img src="@/assets/img/chart/peidianxiang.svg" />
      </div>
      <div class="liumianRol">
        <div v-for="(item, index) in liumianData.liumianRow4Data" :key="index + 'g'" class="liumian_item">
          <div v-if="index == 7">
            <div :class="{ dongli_inline: inline, dongli: !inline }" @click="clickHandleDl('shumian4_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
      <div class="liumianRol">
        <div v-for="(item, index) in liumianData.liumianRow3Data" :key="index + 'h'" class="liumian_item">
          <div v-if="index == 7">
            <div :class="{ dongli_inline: inline, dongli: !inline }" @click="clickHandleDl('shumian3_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
      <div class="liumianRol">
        <div v-for="(item, index) in liumianData.liumianRow2Data" :key="index + 'j'" class="liumian_item">
          <div v-if="index == 7">
            <div :class="{ dongli_inline: inline, dongli: !inline }" @click="clickHandleDl('shumian2_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
      <div class="liumianRol">
        <div v-for="(item, index) in liumianData.liumianRow1Data" :key="index + 'k'" class="liumian_item">
          <div v-if="index == 7">
            <div :class="{ dongli_inline: inline, dongli: !inline }" @click="clickHandleDl('shumian1_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
    </div>
    <!-- 梳棉弹窗控件 -->
    <liumianDialog1 :defaultData="data1" v-if="showModal1_1" ref="liumianDialog1"></liumianDialog1>
    <liumianDialog2 :defaultData="data1" v-if="showModal1_2" ref="liumianDialog2"></liumianDialog2>
    <!-- 动力柜弹窗控件 -->
    <dongliDialog v-if="showDongliModal" ref="dongliDialog"></dongliDialog>
    <!-- 梳棉工艺详情 -->
    <shumian-dialog-tech v-if="techShow" ref="shumianDialogTech"></shumian-dialog-tech>
  </div>
</template>

<script>
import dongliDialog from '@/views/monitorCenter/workChart/components/qcs/dialog/dialog_dongli/index'
import liumianDialog1 from '@/views/monitorCenter/workChart/components/qcs/dialog/dialog_liumian_jwf1211a/index'
import liumianDialog2 from '@/views/monitorCenter/workChart/components/qcs/dialog/dialog_liumian_qf1235/index'
import liumian from '@/views/monitorCenter/workChart/components/qcs/liumian'
import COMMON from '@/utils/common'
import dongLiMenu from '@/assets/data/dongli.json'
import dongliItem from '@/assets/data/dongliItem.json'
export default {
  name: 'ShuMian_5',
  props: {
    msg: String,
    inline: {
      type: Boolean,
      default: false
    }
  },
  components: {
    dongliDialog,
    liumian,
    liumianDialog1,
    liumianDialog2
  },
  data() {
    return {
      liumianData: {
        // 1-8
        liumianRow1Data: [],
        // 9-16
        liumianRow2Data: [],
        // 17-24
        liumianRow3Data: [],
        // 25-32
        liumianRow4Data: [],
        dongLiMenu: {},
        dongLiItem: {}
      },
      showModal1_1: false,
      showModal1_2: false,
      showDongliModal: false,
      techShow: false,
      data1: {}
    }
  },
  // 组件相互调用 需在beforeCreate注册
  beforeCreate: function() {
    this.$options.components.shumianDialogTech = require('@/views/monitorCenter/workChart/components/qcs/dialogBig/dialog_shumian_tech/index').default
  },
  created() {
    this.dongLiMenu = dongLiMenu
    this.dongLiItem = dongliItem
  },
  computed: {
    shuMianJiGroupState() {
      let result
      if (this.$store.state.socketData.length != 0) {
        result = this.$store.state.socketData.filter(item => item.workshop == this.$store.state.workshopNo)
        result = result[0].dsDeviceRealTimeStatusListCotton
      }
      return result
    }
  },
  watch: {
    shuMianJiGroupState: {
      immediate: true,
      handler(val) {
        if (val) {
          this.liumianData.liumianRow1Data = COMMON.devSnFilter(val, 1, 8)
          this.liumianData.liumianRow2Data = COMMON.devSnFilter(val, 9, 16)
          this.liumianData.liumianRow3Data = COMMON.devSnFilter(val, 17, 24)
          this.liumianData.liumianRow4Data = COMMON.devSnFilter(val, 25, 32)
        } else {
          this.liumianData.liumianRow1Data = []
          this.liumianData.liumianRow2Data = []
          this.liumianData.liumianRow3Data = []
          this.liumianData.liumianRow4Data = []
        }
      }
    }
  },
  methods: {
    closeHandle() {
      this.showModal1_1 = false
      this.showModal1_2 = false
      this.showDongliModal = false
    },
    clickHandle(flag, item) {
      this.data1 = item
      //从socket最外部找班次（后端就不能把班次返回到车台里面或者接口里面吗凸(艹皿艹 )）
      this.data1.classes = this.$store.state.workshopData.shiftPreSpinTxt
      switch (item.deviceTable) {
        case 'zjc_jwf1211a':
          this.showModal1_1 = true
          break
        case 'zjc_qf1235':
          this.showModal1_2 = true
          break
        default:
          this.showModal1_1 = true
          break
      }
    },
    clickHandleDl(item) {
      this.showDongliModal = true
      var dialogData = this.dongLiItem[`${item}_${this.$store.state.workshopNo}`]
      this.$nextTick(() => {
        this.$refs.dongliDialog.showDialog(dialogData)
      })
    },
    showDialogTech() {
      this.techShow = true
    },
    closeDialogTech() {
      this.techShow = false
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@/assets/less/workshop.less';
.dongli_inline {
  position: absolute;
  transform: scale(2);
  left: 400px;
  img {
    width: 10px;
    height: 28px;
  }
}
</style>
